import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;


public class PLPlayerBasicShapes extends PLPlayer {
	// here there will be an object for image processing module
	
	Dimension canvasDimension = PLGuiInfo.Obj().GetDimension();
	int w = (int) canvasDimension.getWidth(); 
	int h = (int) canvasDimension.getHeight(); 
	
	ArrayList<PLShape> trainShapes = new ArrayList<PLShape>(); 
	Point start; 
	Point end; 
	
	//define a quadrant system of critical points like the matrix below
	// 0 w1 w2 w3 w4
	//h1
	//h2
	//h3
	//h4
	int w1 = (int)((double)w/2 - w/4); 
	int w2 = (int)((double)w/2); 
	int w3 = (int)((double)w/2 + w/4); 
	int w4 = w; 
	int h1 = (int)((double)h/2 - h/4); 
	int h2 = (int)((double)h/2); 
	int h3 = (int)((double)h/2 + h/4); 
	int h4 = h; 
	
	//define the 25 points at all of the intersections
	//abcde
	//fghij
	//klmno
	//pqrst
	//ubwxy
	Point a = new Point(0,0); 
	Point b = new Point (w1,0); 
	Point c = new Point(w2,0); 
	Point d = new Point(w3,0);
	Point e = new Point(w4,0);
	Point f = new Point(0,h1);
	Point g = new Point (w1,h1); 
	Point hLetter = new Point(w2, h1); 
	Point i = new Point(w3, h1); 
	Point j = new Point(w4 ,h1); 
	Point k = new Point(0 ,h2);  
	Point l = new Point(w1 ,h2); 
	Point m = new Point(w2 ,h2); 
	Point n = new Point(w3 ,h2);  
	Point o = new Point(w4 ,h2); 
	Point p =new Point (0 ,h3); 
	Point q =new Point (w1 ,h3); 
	Point r =new Point (w2 ,h3); 
	Point s = new Point(w3 ,h3); 
	Point t = new Point(w4 ,h3); 
	Point u =new Point (0 ,h2); 
	Point v = new Point(w1 ,h4); 
	Point wLetter = new Point(w2 ,h4);  
	Point x = new Point(w3 ,h4); 
	Point y = new Point(w4 ,h4); 
	//array of coordinate system
	Point[] allPoints = {a, c, b, d, e, f, g, hLetter, i, j, k, l, m, n, o, p, q, r, s, t, u, v, wLetter, x, y}; 
	//a subset of the critical coordinates on the inside of the matrix 
	//Point[] cc = {allPoints[7],allPoints[8],allPoints[9],allPoints[12],allPoints[13],allPoints[14],allPoints[17],allPoints[18],allPoints[19]}; 
	Point[] cc = {allPoints[3],allPoints[3],allPoints[3],allPoints[3]}; 


	int mQueryNumber =0;
	
	public PLPlayerBasicShapes(String name) {
		super(name);
		Init();
	}

	public int GetNumShapes() {
		return trainShapes.size();
	}
	
		
	public void BeginShapeQueries() {mQueryNumber =0; }
	
	// given a query shape, comes up with a response after qurying both the 
	public float GenResponse(PLShape query, PLOutShape  outResponse) {
		if (mQueryNumber >= GetNumShapes())
			return 0;

		outResponse.SetShape(trainShapes.get(mQueryNumber));
		++mQueryNumber;
		return 1;
	}

	private boolean Init() {
		GenShapes(); 
		return true;
	}
	
	private void GenShapes(){
		
		PLShape sh = null;	
		PLShape.ShapeIdT id = PLShape.ShapeIdT.kLine; 
		sh = PLShapeUtils.MakeNewShape(id, g, i); 
		trainShapes.add(sh); 
		//horizontal 
		sh = PLShapeUtils.MakeNewShape(id, hLetter, r); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, q, i); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, g, s); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, b, q); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, d, s); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, i, a); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, i, s); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, r, c); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, a, r); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, j, l); 
		trainShapes.add(sh); 

		sh = PLShapeUtils.MakeNewShape(id, c, wLetter); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, d, u); 
		trainShapes.add(sh); 
		
		sh = PLShapeUtils.MakeNewShape(id, q, e); 
		trainShapes.add(sh); 
		
		
		
		
		
		
		
		
		
		
		
		/*
		 * TODO Fix this for later versions
		for (int i = 0; i < cc.length ; i++){
			//cycle through all of the critical coordinations (Point[]cc...)
			for (PLShape.ShapeIdT id : PLShape.ShapeIdT.values()) {
				if 	(id == PLShape.ShapeIdT.kMin ||
						id == PLShape.ShapeIdT.kMax)
					continue;
				
				//cycle through all of the shapes and assign them for this coordinate
				sh = PLShapeUtils.MakeNewShape(id, new Point(cc[i].x - w/2, cc[i].y), new Point(cc[i].x + w/2, cc[i].y)); 
				trainShapes.add(sh); 
				if(id == PLShape.ShapeIdT.kLine) {
					//horizontal version
					sh = PLShapeUtils.MakeNewShape(id, new Point(cc[i].x, cc[i].y-h/2), new Point(cc[i].x, cc[i].y + h/2)); 
					trainShapes.add(sh); 
				}
				
			}
		}
		*/

		
	}


	
	
}
